import { pget, ppostJson, post } from '@/utils/req'
import { modalApi } from '@/utils/modalReq'

// 采购申请分页
export function getTableList(data: any) {
	return pget(
		`${modalApi.purchase}/shopec-purchase-requisition/requisition/page`,
		data,
	)
}

// 采购申请全量分页
export function getAllApplyList(query?: any) {
	return pget(
		`${modalApi.purchase}/shopec-purchase-requisition/requisition/availableList`,
		query,
	)
}

// 新增采购申请
export function addApply(data: any) {
	return ppostJson(
		`${modalApi.purchase}/shopec-purchase-requisition/requisition/save`,
		data,
	)
}
/** 采购申请保存 */
export function applySaveTemporary(data: any) {
	return ppostJson(
		`${modalApi.purchase}/shopec-purchase-requisition/requisition/saveTemporary`,
		data,
	);
}

// 修改采购申请
export function editApply(id: string, data: any) {
	return ppostJson(
		`${modalApi.purchase}/shopec-purchase-requisition/requisition/update/${id}`,
		data,
	)
}

// 删除采购申请
export function deleteApply(data: { ids: string }) {
	return post(
		`${modalApi.purchase}/shopec-purchase-requisition/requisition/remove`,
		data,
	)
}

// 查看采购申请
export function viewApply(id: string) {
	return pget(
		`${modalApi.purchase}/shopec-purchase-requisition/requisition/detail/${id}`,
	)
}

/** 保存采购申请导入数据 */
export function requisitionImport(query?: any) {
	return ppostJson(
		`${modalApi.purchase}/shopec-purchase-requisition/requisition/import/${query.batch}`,
	)
}

/** 字典查询 */
export function dictByCode(code?: any) {
	return pget(
		`${modalApi.common}/shopec-systembase/dict/getDictList/${code}`,
	)
}

/** 可用费用立项列表 */
export function getInitiationAccessList(query: any) {
	return pget(
		`${modalApi.purchase}/shopec-purchase-applycost/applycost/availableList`,
		query,
	)
}

/** 可用费用立项分页列表 */
export function getPageInitiationAccessList(query: any) {
	return pget(
		`${modalApi.purchase}/shopec-purchase-applycost/applycost/availablePage`,
		query,
	)
}


// 工作流接口
/** 流程新增 */
export function contractProcessAdd(data: any) {
	return ppostJson(
		`${modalApi.purchase}/shopec-purchase-requisition/requisition/submitFlow`,
		data,
	)
}
/** 推荐供应商分页列表 */
export function getAmcpurchasesupplier(query: any) {
	return pget(
		`${modalApi.purchase}/shopec-purchase-supplier/amcpurchasesupplier/list`,
		query,
	)
}
/** 获取流程配置 */
export function getProcessPropertys(query: any) {
	return pget(
		`${modalApi.purchase}/shopec-purchase-utils/utils/getProcessPropertys`,
		query,
	)
}
/** 获取流程节点自定义配置 */
export function getNodePropertys(query: any) {
	return pget(
		`${modalApi.purchase}/shopec-purchase-utils/utils/getNodePropertys`,
		query,
	)
}
// 采购申请审核
export function contractAuditFlow(data: any) {
	return ppostJson(
		`${modalApi.purchase}/shopec-purchase-requisition/requisition/auditFlow`,
		data,
	)
}
// 作废采购申请后重新发起审核
export function contractRelaunchFlow(id: any, data: any) {
	return ppostJson(
		`${modalApi.purchase}/shopec-purchase-requisition/requisition/relaunchFlow/${id}`,
		data,
	)
}
